package com.pig.graduate.controller.produce;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig.graduate.domain.event.EventEntry;
import com.pig.graduate.domain.event.EventExit;
import com.pig.graduate.domain.event.EventTransferDormitory;
import com.pig.graduate.domain.produce.ProduceBoar;
import com.pig.graduate.domain.produce.ProducePig;
import com.pig.graduate.result.MyResult;
import com.pig.graduate.service.produce.ProducePigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.Serializable;
import java.util.List;

/**
 * (ProducePig)表控制层
 *
 * @author makejava
 * @since 2023-03-13 16:32:22
 */
@Api(tags = {"肉猪管理"}, description = "肉猪管理")
@RestController
@RequestMapping("produce/pig")
public class ProducePigController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private ProducePigService producePigService;

    /**
     * 种猪列表
     * @param producePig
     * @return
     */
    @ApiOperation(value = "肉猪列表",notes = "肉猪列表")
    @PostMapping("/list")
    public MyResult boarList(@RequestBody ProducePig producePig){
        // 查询所有栋舍信息
        return producePigService.pigList(producePig);
    }

    /**
     * 进场
     * @param eventEntry
     * @return
     */
    @ApiOperation(value = "肉猪进场",notes = "肉猪进场")
    @PostMapping("/pigEntry")
    public MyResult boarEntry(@RequestBody EventEntry eventEntry){
        return producePigService.pigEntry(eventEntry);
    }

    /**
     * 转舍
     * @param eventTransferDormitory
     * @return
     */
    @ApiOperation(value = "肉猪转舍",notes = "肉猪转舍")
    @PostMapping("/pigMoveBuildings")
    public MyResult pigMoveBuildings(@RequestBody @Valid EventTransferDormitory eventTransferDormitory){
        return producePigService.pigMoveBuildings(eventTransferDormitory);
    }

    /**
     * 肉猪离场
     * @param eventExit
     * @return
     */
    @ApiOperation(value = "肉猪离场",notes = "肉猪离场")
    @PostMapping("/pigLeave")
    public MyResult pigLeave(@RequestBody EventExit eventExit){
        return producePigService.pigLeave(eventExit);
    }


    /**
     * 肉猪删除
     * @param id
     * @return
     */
    @ApiOperation(value = "肉猪删除",notes = "肉猪删除")
    @DeleteMapping("/pigDelete/{id}")
    public MyResult pigDelete(@PathVariable(value = "id") Long id){
        producePigService.removeById(id);
        return MyResult.success();
    }
}

